package hk.m4s.lr.repair.test.ui.adapter;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import framework.common.Constant;
import framework.utils.SharedPreferencesUtils;
import hk.m4s.lr.repair.test.R;
import hk.m4s.lr.repair.test.ui.adapter.ItemCareAdapter;
import hk.m4s.lr.repair.test.ui.user.MyCareGoodsActivity;
import hk.m4s.lr.repair.test.views.listview.InnerListView;
import okhttp3.Response;

/**
 * @author
 */
public class MyCareAdapter extends BaseAdapter {
    private MyCareGoodsActivity context;
    public List<String> items;
    private List<String> myjiangLiModelList;
    private ItemCareAdapter adapter;

    public MyCareAdapter(MyCareGoodsActivity context,
                         List<String> items) {
        this.context = context;
        this.items = items;
    }

    public int getCount() {
        return 3;
    }

    public Object getItem(int position) {
        return getView(position, null, null);
    }

    public long getItemId(int position) {
        return position;
    }

    @SuppressLint("InflateParams")
    public View getView(final int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        if (convertView == null) {
            convertView = LayoutInflater.from(context).inflate(
                    R.layout.list_item_my_tui_order, null);
            holder = new ViewHolder();
            holder.order_shop_name = (TextView) convertView.findViewById(R.id.order_shop_name);
            holder.itemList = (InnerListView) convertView.findViewById(R.id.itemList);
            holder.header = (RelativeLayout) convertView.findViewById(R.id.header);

            holder.goodsEnValue = (TextView) convertView.findViewById(R.id.goodsEnValue);

            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        holder.header.setTag(position);
//        MyOrderTuiModel.ListBean model = items.get(position);
//        holder.order_shop_time.setText("服务单号: " + model.getId());
//        holder.order_shop_totlaprice.setText(MoneyTool.getLocalMoney(model.getActual_money()));
//        if (model.getGoodsInfo() != null) {
//            myjiangLiModelList = new ArrayList<>();
//            for (MyOrderTuiModel.ListBean.GoodsInfoBean detailBean : model.getGoodsInfo()) {
//                MyWaiteOrderModel waiteOrderModel = new MyWaiteOrderModel();
//                waiteOrderModel.setTime(AppTools.getStrTime(detailBean.getAddTime()));
//                waiteOrderModel.setGoods_id(detailBean.getGoods_id());
//                waiteOrderModel.setName(detailBean.getGoods_name());
//                waiteOrderModel.setPrice(detailBean.getGoods_price());
//                waiteOrderModel.setSize(detailBean.getGoods_color());
//                waiteOrderModel.setBuyNum(detailBean.getGoods_num());
//                waiteOrderModel.setState(detailBean.getStatus());
//                waiteOrderModel.setImg(detailBean.getImg());
//                myjiangLiModelList.add(waiteOrderModel);
//            }
            adapter = new ItemCareAdapter(context, myjiangLiModelList);
            holder.itemList.setAdapter(adapter);
//        }
        return convertView;
    }

    private class ViewHolder {
        TextView order_shop_name;
        TextView order_shop_state;
        TextView goodsEnValue;
        private RelativeLayout header;
        InnerListView itemList;
    }

}
